﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace 普通策略模式
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            // 获取订单
            Order order = new Order();
            order.Goods = tbGoods.Text;
            order.UnitPrice = double.Parse(tbUnitPrice.Text);
            order.Count = int.Parse(tbCount.Text);

            // 计算价格
            Role role = (bool)rbVip.IsChecked ? Role.Vip : Role.Common;
            IStrategyContext context = new StrategyContext(role);
            double price = context.CalculatePrice(order);

            lbResult.Content = price.ToString();
        }
    }
}
